#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.12.0
 Author:         myName

 Script Function:
	Template AutoIt script.

#ce ----------------------------------------------------------------------------

#Include <Array.au3>
#Include <Constants.au3>
#Include <File.au3>
#Include <Process.au3>
#Include <String.au3>

$sSource = "N:\movies\Movies\720p\"

If StringRight( $sSource , 1 ) <> '\' Then $sSource &= '\'

$cExtensions = '*.3gp;*.avi;*.avs;*.divx;*.f4v;*.flac;*.flv;*.m2ts;*.m4v;*.mkv;*.mp3;*.mp4;*.mpg;*.ogg;*.ogm;*.ts;*.vob'

$aAllFiles = _FileListToArrayRec( $sSource , $cExtensions , 1 , 1 , 0 , 2 )
;_ArrayDisplay($aAllFiles)
If IsArray( $aAllFiles ) Then
	For $ii = 1 To $aAllFiles[0]
		_Macros( $aAllFiles[$ii] )

		FileSetAttrib( $sFileDir , '-RASHNOT' , 1 )
		FileSetAttrib( $sFileDir & '*' , '-RASHNOT' , 1 )
		DirMove( $sFileDir , StringLeft( $sFileDir , StringInStr( $sFileDir , '\' , 0 , -3 )) , 1 )
	Next
EndIf

MsgBox ( 0 , 'Finished:' , 'Batch Operation Complete' )




Func _Macros( $sFile )
	Global $sFileDir    = StringLeft     ( $sFile     , StringInStr( $sFile     , '\' , 0 , -1 ) )
	Global $sFileExt    = StringTrimLeft ( $sFile     , StringInStr( $sFile     , '.' , 0 , -1 ) - 1 )
	Global $sFileName   = StringTrimLeft ( $sFile     , StringInStr( $sFile     , '\' , 0 , -1 ) )
	Global $sShortName  = StringLeft     ( $sFileName , StringInStr( $sFileName , '.' , 0 , -1 ) - 1 )
	Global $sParent     = StringTrimLeft ( $sFileDir  , StringInStr( $sFileDir  , '\' , 0 , -2 ) )
	Global $sFolderName = StringTrimRight( StringTrimLeft( $sFileDir , StringInStr( $sFileDir , '\' , 0 , -2 ) ) , 1 )
EndFunc
